<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <style type="text/css">
    	#nav2{
    		margin: 40px auto;
    	}
    	.span5{
    		height: 25px;
    	}
    </style>
  </head>
  <body>
    <%@ include file="main.jsp"%>
    <div class="container">
    	<form class="form-horizontal" action="editProvider" method="post" style="margin-bottom:0px;">
			<div id="myModal" class="modal hide fade in" style="dispaly:none;">
				<div class="modal-header">
					<h3>修改客户信息</h3>
				</div>
				<div class="modal-body">
					<fieldset>
					    <input type="hidden" id="providerid" class="span5" name="id">
					    <div class="control-group">
							<label class="control-label" for="input01">供应商名称：</label>
							<div class="controls">
								<input type="text" id="providername" class="span5" name="providername">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">供应商邮编：</label>
							<div class="controls">
								<input type="text" id="zipcode" class="span5" name="zipcode">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">公司地址：</label>
							<div class="controls">
								<input type="text" id="address" class="span5" name="address">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">联系人：</label>
							<div class="controls">
								<input type="text" id="linkman" class="span5" name="linkman">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">联系人电话：</label>
							<div class="controls">
								<input type="text" id="tel" class="span5" name="tel">
							</div>
						</div>
					    <div class="control-group">
							<label class="control-label">开户银行：</label>
							<div class="controls">
								<input type="text" id="bank" class="span5" name="bank">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">银行账号：</label>
							<div class="controls">
								<input type="text" id="account" class="span5" name="account">
							</div>
						</div>
					</fieldset>
				</div>
				<div class="modal-footer">
					<button class="btn btn-primary" type="submit"><i class="icon-ok-sign icon-white"></i>保存</button>
					<a class="btn" href="#" data-dismiss="modal"><i class="icon-remove-sign"></i>取消</a>
				</div>
			</div>
		</form>
		<div id="myModal2" class="modal hide fade in" style="dispaly:none;">
			<div class="modal-header">
				<h3>系统信息提示：</h3>
			</div>
			<div class="modal-body">
				确定要删除信息吗？
			</div>
			<div class="modal-footer">
				<input id="removeBtn" type="button" class="btn btn-success" value="确定"/>
				<input type="button" class="btn" data-dismiss="modal" value="取消"/>
			</div>
		</div>
   		<div class="tabbable" style="margin-bottom: 9px;">
		    <ul class="nav nav-tabs">
		    <li class="active"><a href="#1" data-toggle="tab">全部供应商信息</a></li>
		    <li><a href="#2" data-toggle="tab">添加供应商信息</a></li>
		    </ul>
		    <div class="tab-content">
		    <div class="tab-pane active" id="1">
		    	<table class="table table-bordered" style="border-width: 2px">
					<thead>
						<tr>
							<th>供应商编号</th>
							<th>供应商名称</th>
							<th>邮编</th>
							<th>公司地址</th>
							<th>联系人</th>
							<th>联系人电话</th>
							<th>卡户银行</th>
							<th>银行账号</th>
							<th>操作</th>
					  	</tr>
				 	</thead>
				 	<tbody>
				 		<c:forEach items="${providerList}" var="provider">
					 		<tr>
								<td>${provider.id}</td>
								<td>${provider.providername}</td>
								<td>${provider.zipcode }</td>
								<td>${provider.address }</td>
								<td>${provider.linkman }</td>
								<td>${provider.tel }</td>
								<td>${provider.bank }</td>
								<td>${provider.account}</td>
								<td>
									<a class="btn btn-primary" rel="${provider.id}" href="#myModal" data-toggle="modal">编辑</a>
									<a class="btn btn-danger" rel="${provider.id}" href="#myModal2" data-toggle="modal">删除</a>
								</td>
							</tr>
						</c:forEach>
				 	</tbody>
				</table>
		    </div>
		    <div class="tab-pane" id="2">
		    	<form class="form-horizontal" action = "addProvider" method="post">
				    <fieldset>
					    <div class="control-group">
							<label class="control-label" for="input01">供应商编号：</label>
							<div class="controls">
								<input type="text" class="span5" name="id">
							</div>
						</div>
					    <div class="control-group">
							<label class="control-label" for="input01">供应商名称：</label>
							<div class="controls">
								<input type="text" class="span5" name="providername">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">供应商邮编：</label>
							<div class="controls">
								<input type="text" class="span5" name="zipcode">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">公司地址：</label>
							<div class="controls">
								<input type="text" class="span5" name="address">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">联系人：</label>
							<div class="controls">
								<input type="text" class="span5" name="linkman">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">联系人电话：</label>
							<div class="controls">
								<input type="text" class="span5" name="tel">
							</div>
						</div>
					    <div class="control-group">
							<label class="control-label" for="multiSelect">开户银行：</label>
							<div class="controls">
								<select id="multiSelect" name="bank">
									<option></option>
									<option>农业银行</option>
									<option>建设银行</option>
									<option>工商银行</option>
									<option>邮政银行</option>
								</select>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">银行账号：</label>
							<div class="controls">
								<input type="text" class="span5" name="account">
							</div>
						</div>
					    <div class="form-actions">
							<button class="btn btn-primary" type="submit"><i class="icon-ok-sign icon-white"></i>保存</button>
							<a class="btn" href="sales.jspx?task=list"><i class="icon-remove-sign"></i>取消</a>
						</div>
				    </fieldset>
			    </form>
		    </div>
		    </div>
		</div>
	</div>
	<script type="text/javascript">
		var removeId ="";
		$(document).ready(function(){
			$("td .btn").click(function(){
				$.get("findByProviderId"+$(this).attr("rel"),function(provider){
					$("#providerid").val(provider.id);
					$("#providername").val(provider.providername);
					$("#zipcode").val(provider.zipcode);
					$("#address").val(provider.address);
					$("#linkman").val(provider.linkman);
					$("#tel").val(provider.tel);
					$("#bank").val(provider.bank);
					$("#account").val(provider.account);
				});
			});
			$("td .btn").click(function(){
				removeId = $(this).attr("rel");
			});
			$("#removeBtn").click(function(){
	    		window.location.href="delProvider" + removeId;
	    	});
		});
	</script>
  </body>
</html>
